home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-11-28 | 6.5 KB | 255 lines | [TEXT/MPS ] |
- # This script runs CFront and gC with appropriate options.
- #
- # Copyright © 1990 Apple Computer, Inc.
-
- set echo 0 # Build turns echo on, grumble.
- set exit 0 # Have to be able to clean up after failed commands.
-
- # Default is to run everything.
- set cfront-only 0
-
- If ¬ "{CPlusScratch}" ; Set CPlusScratch ':' ; End
- set output-filename ""
- set cfront-options "-w3 -z3 -y {CPlusScratch}"
- set gc-options ""
- set tmp ":"
-
- set echo-cmds 1
- set quiet-flag 1
-
- set dash-mc68020 0
- set dash-m 0
-
- # Scan all the command line arguments, distributing them to the appropriate
- # programs' command lines, translating when necessary.
- loop
- break if {#} == 0
- if "{1}" =~ /-a?*/
- if "{1}" =~ /-a[01]«0,1»/
- set cfront-options "{cfront-options} {1}"
- else if "{1}" =~ /-ansi/
- set gc-options "{gc-options} -ansi"
- else if "{1}" =~ /-asm/
- set gc-options "{gc-options} -asm"
- end
- else if "{1}" =~ /-b?*/
- if "{1}" =~ /-b/
- set gc-options "{gc-options} -b"
- else if "{1}" =~ /-b2/
- echo Warning: -b2 ignored, substituting -b
- set gc-options "{gc-options} -b"
- else if "{1}" =~ /-b3/
- echo Warning: -b3 ignored, substituting -b
- set gc-options "{gc-options} -b"
- else if "{1}" =~ /-bigseg/
- echo Warning: Ignoring -bigseg
- end
- else if "{1}" =~ /-c/
- set cfront-only 1
- else if "{1}" =~ /-d?*/
- if "{1}" =~ /-d/
- shift 1
- set cfront-options "{cfront-options} -d {1}"
- else if "{1}" =~ /-d?+/
- set gc-options "{gc-options} {1}"
- end
- else if "{1}" =~ /-e?*/
- if "{1}" =~ /-e/
- set cfront-only 1
- set cfront-options "{cfront-options} -e"
- else if "{1}" =~ /-e2/
- set cfront-only 1
- set cfront-options "{cfront-options} -e2"
- else if "{1}" =~ /-elems881/
- set cfront-options "{cfront-options} -elems881"
- set gc-options "{gc-options} -elems881"
- end
- else if "{1}" =~ /-f?*/
- if "{1}" =~ /-f/
- shift 1
- set cfront-options "{cfront-options} -f '{1}'"
- else if "{1}" =~ /-fx/
- shift 1
- if "{1}" =~ /30/
- set gc-options "{gc-options} -fx 30 -mnoseg"
- else
- echo Warning: -fx {1} being ignored
- end
- else if "{1}" =~ /-f?+/
- set gc-options "{gc-options} {1}"
- end
- else if "{1}" =~ /-i/
- shift 1
- set cfront-options "{cfront-options} -i '{1}'"
- # at least in theory, cfront output does no inclusion
- else if "{1}" =~ /-k/
- shift 1
- echo Warning: Ignoring -k
- else if "{1}" =~ /-m?*/
- if "{1}" =~ /-m/
- set dash-m 1
- else if "{1}" =~ /-maxerrors/
- shift 1
- set cfront-options "{cfront-options} -maxerrors {1}"
- else if "{1}" =~ /-mbg/
- shift 1
- if "{1}" =~ /off/
- set cfront-options "{cfront-options} -mbg {1}"
- set gc-options "{gc-options} -mbg {1}"
- else if "{1}" =~ /full/
- # default case
- else
- echo Warning: only -mbg off and -mbg full are understood
- end
- else if "{1}" =~ /-mc68020/
- set dash-mc68020 1
- else if "{1}" =~ /-mc68881/
- set cfront-options "{cfront-options} -mc68881"
- set gc-options "{gc-options} -mc68881"
- else if "{1}" =~ /-mf/
- set cfront-options "{cfront-options} -mf"
- else if "{1}" =~ /-mnoseg/
- set gc-options "{gc-options} -mnoseg"
- else if "{1}" =~ /-mtbl[01]/
- set cfront-options "{cfront-options} {1}"
- end
- else if "{1}" =~ /-notonce/
- echo Warning: -notonce being ignored
- else if "{1}" =~ /-n/
- echo Warning: -n being ignored
- else if "{1}" =~ /-o?*/
- if "{1}" =~ /-opt/
- shift 1
- set gc-options "{gc-options} -opt '{1}'"
- else if "{1}" =~ /-o/
- shift 1
- set output-filename "{1}"
- end
- else if "{1}" =~ /-p?*/
- if "{1}" =~ /-p/
- set cfront-options "{cfront-options} -v"
- set quiet-flag 0
- set gc-options "{gc-options} -p"
- set echo-cmds 1
- else if "{1}" =~ /-pedantic/
- set gc-options "{gc-options} -pedantic"
- end
- else if "{1}" =~ /-s?*/
- if "{1}" =~ /-s/
- shift 1
- set gc-options "{gc-options} -s '{1}'"
- else if "{1}" =~ /-sym/
- shift 1
- set gc-options "{gc-options} -sym {1}"
- end
- else if "{1}" =~ /-t?*/
- if "{1}" =~ /-trace/
- shift 1
- set gc-options "{gc-options} -trace '{1}'"
- else if "{1}" =~ /-t/
- set quiet-flag 0
- else if "{1}" =~ /-tools/
- shift 1
- set gc-options "{gc-options} -tools {1}"
- else if "{1}" =~ /-traditional/
- set gc-options "{gc-options} -traditional {1}"
- end
- else if "{1}" =~ /-u/
- shift 1
- set cfront-options "{cfront-options} -u '{1}'"
- else if "{1}" =~ /-vtbl[01]/
- set cfront-options "{cfront-options} {1}"
- else if "{1}" =~ /-w?*/
- if "{1}" =~ /-w[2]«0,1»/
- set cfront-options "{cfront-options} {1}"
- set gc-options "{gc-options} -w"
- else if "{1}" =~ /-w[13]/
- set cfront-options "{cfront-options} {1}"
- end
- else if "{1}" =~ /-y/
- shift 1
- set cfront-options "{cfront-options} -y '{1}'"
- set gc-options "{gc-options} -y '{1}'"
- set tmp "{1}"
- else if "{1}" =~ /-z?+/
- set cfront-options "{cfront-options} {1}"
- else if "{1}" =~ /-?+/
- set gc-options "{gc-options} {1}" # pass random stuff to gC
- else
- set input-filename "{1}"
- end
- shift 1
- end
-
- if {dash-m}
- set gc-options "{gc-options} -m"
- if (! {dash-mc68020})
- echo Warning: -m implies -mc68020
- end
- end
-
- if {dash-mc68020} || {dash-m}
- set cfront-options "{cfront-options} -mc68020"
- set gc-options "{gc-options} -mc68020"
- end
-
- # Fix up details of parameters to the tools.
- if "{input-filename}" == ""
- set tmp-filename "{tmp}stdin"
- else
- if "{input-filename}" =~ /:*([¬:]+:*)*([¬:]+)®1/
- set tmp-filename "{tmp}{®1}"
- else
- echo "### {0} - can’t parse “{input-filename}”"
- exit 2
- end
- end
-
- if {cfront-only}
- set cf-filename ""
- set cfront-redirect ""
- else
- set cf-filename "{tmp-filename}".cf
- set cfront-redirect ">"
- if "{output-filename}" == ""
- set output-filename "{input-filename}".o
- end
- end
-
- # Run the two things in order
- if {echo-cmds}
- echo "CFront {cfront-options} -c '{input-filename}' {cfront-redirect} '{cf-filename}'" > dev:stderr
- end
- CFront {cfront-options} -c "{input-filename}" {cfront-redirect} "{cf-filename}"
- set cfront-status {status}
- exit {cfront-status} if {cfront-only}
-
- if {cfront-status} == 0
- if {echo-cmds}
- echo "gC {gc-options} '{cf-filename}' -o '{output-filename}'" > dev:stderr
- end
- gC {gc-options} "{cf-filename}" -o "{output-filename}"
- if {status} == 0
- # complete success
- if `exists -f "{tmp}"C.pipe.obj2`
- Lib -o "{tmp}"Lib.out "{output-filename}" "{tmp}"C.pipe.obj2
- duplicate -y "{tmp}"Lib.out "{output-filename}"
- delete -i "{tmp}"Lib.out
- delete -i "{tmp}"C.pipe.obj2
- end
- delete -i "{cf-filename}"
- delete -i "{tmp}"C.pipe.cmnd
- else
- delete -i "{cf-filename}"
- delete -i "{tmp}"C.pipe.cmnd
- delete -i "{tmp}"C.pipe.obj2
- delete -i "{output-filename}"
- exit 2
- end
- else
- delete -i "{cf-filename}"
- delete -i "{tmp}"C.pipe.cmnd
- delete -i "{tmp}"C.pipe.obj2
- exit 2
- end
-